package red.mlz.module.module.material.mapper;


import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import red.mlz.module.module.material.entity.Material;

import java.math.BigInteger;
import java.util.List;

/**
 * <p>
 * 物料表 Mapper 接口
 * </p>
 *
 * @author mlzred
 * @since 2025-04-03
 */
public interface MaterialMapper {

    @Select("select * from material WHERE id=#{id} and is_deleted = 0")
    Material getById(@Param("id") BigInteger id);

    @Select("select * from material WHERE id=#{id}")
    Material extractById(@Param("id") BigInteger id);

    int update(@Param("Material") Material material);

    int insert(@Param("Material") Material material);

    @Update("update material set is_deleted=1, update_time=#{time} where id=#{id} limit 1")
    void delete(@Param("id") BigInteger id, @Param("time") Integer time);

    List<Material> getMaterialList(@Param("begin") int begin, @Param("size") int size, @Param("orderBy") String orderBy,
                                   @Param("keyword") String keyword, @Param("categoryIds") String categoryIds);

    int getMaterialsTotalForConsole(@Param("keyword") String keyword, @Param("categoryIds") String categoryIds);
}
